package ru.gerunn;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;

public class DAOClient {

	public static void main(String[] args) {
		try {
			DAO dao = new DAO();
			
			Connection conn = dao.getConnection("jdbc:db2://10.0.0.45:50000/LETDBACK", "db2inst1", "G]g.eJmd*59BP");
			
			//PreparedStatement ps = conn.prepareStatement("insert into logstest4.temp (text) values (?)");
			//ps.setString(1, "2");
			//ps.executeUpdate();
			//ps.close();

			PreparedStatement ps = conn.prepareStatement("update logstest4.temp set text = ? where id = ?");
			ps.setString(1, "changed");
			ps.setInt(2, 1);
			ps.executeUpdate();
			ps.close();
			
			conn.close();
		} catch (SQLException e) {
			e.printStackTrace();
			while (e != null) {
				System.err.println("Error msg: " + e.getMessage());
				System.err.println("SQLSTATE: " + e.getSQLState());
				System.err.println("Error code: " + e.getErrorCode());
				e.printStackTrace();
				e = e.getNextException(); // For drivers that support chained exceptions
			}
		}
	}

}
